<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        let arr = []

        for (let i = 1; i <= 102; i++) {
            arr.push(i)
        }

        console.log(arr.slice(0, 5));   //1-1 * 5  0    + 5
        console.log(arr.slice(5, 10));  //2-1 * 5   5  + 5
        console.log(arr.slice(10, 15));  //3-1 * 5  10  + 5
        // let start = (pageIndex - 1) * pageSize
        // let end = start + pageSize
        // console.log(arr.slice(start, end));

        function getPageList(pageIndex, pageSize) {
            console.log('共有' + Math.ceil(arr.length / pageSize) + "页");
            let start = (pageIndex - 1) * pageSize
            let end = start + pageSize
            console.log(start, end);
            return arr.slice(start, end)
        }

        getPageList(1, 10)
        getPageList(2, 10)
        getPageList(3, 10)
        getPageList(1, 20)





    </script>
</body>

</html>